/*
 * NeighbourhoodInfo.java
 *
 * Created on 07 March 2008, 16:16
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */
import java.util.*;
/**
 *
 * @author Hussein Patwa
 */
@SuppressWarnings("all")
public class NeighbourhoodInfo extends Matrix{
    
    /** Creates a new instance of NeighbourhoodInfo */
    public NeighbourhoodInfo() {
        super();
    }
    
    
    /** Creates a new instance of NeighbourhoodInfo */
    public NeighbourhoodInfo(Vector dat) {
        super(dat);
    }
    
    
    public boolean areNeighbours(int a1,int a2){
        //first retrieve the row for a1
        //then retrieve the element at a2 in that row
        //if that element is non-zero return true else return flase
        Vector rowV = (Vector)data.get(a1);
        Double rtn = (Double)rowV.get(a2);
        if(rtn.doubleValue()!=0)
            return true;
        else return false;
    }

    
    public Vector getNeighbourhoodAreaIDs(int area){
        Vector rtn = new Vector();
        Vector row = (Vector)data.get(area);
        for(int i=0;i<row.size();i++){
            if(areNeighbours(area,i)){ 
                rtn.add(new Integer(i));
            }
        }
        return rtn;
    }
}
